Skip to content

move setting of initPending to false only after initializing the jdk log manager, fix #646#647

Merged
danfickle merged 2 commits into
danfickle:open-dev-v1from
syjer:646-fix-init
Feb 12, 2021
Merged

move setting of initPending to false only after initializing the jdk log manager, fix #646#647
danfickle merged 2 commits into
danfickle:open-dev-v1from
syjer:646-fix-init

Conversation

@syjer

@syjer syjer commented Feb 8, 2021

Copy link
Copy Markdown
Contributor

Seems to fix the issue as generated by the test case. Not 100% sure it cover all cases.

Fix issue #646 .

To be noted, we may need to cleanup the init part of the logging...

@syjer syjer changed the title #646 move setting of initPending to false only after initializing the jdk log manager move setting of initPending to false only after initializing the jdk log manager, fix #646 Feb 8, 2021
Without volatile we can have the situation where thread 2 sees the value of initPending to be false and thus doesn't go through the synced section but sees loggers as not yet visible.

This was rare and the test only failed on the first run on my machine before always passing.

Hopefully, it should always work now. Fingers crossed.

NOTE: Both of the changed classes use a version of the "double checked locking" pattern which the internet says requires volatile.
@danfickle

Copy link
Copy Markdown
Owner

Thanks @syjer,

I've added a commit with the use of volatile. I still can't guarantee it is correct as the test only failed the very first time I started my computer.

@syjer

syjer commented Feb 11, 2021

Copy link
Copy Markdown
Contributor Author

you are absolutely right about the volatile! Surprising that the test on my pc was not catching this case (maybe increasing the number of concurrent thread?).

@danfickle
danfickle merged commit 67913a4 into danfickle:open-dev-v1 Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants